package com.share.example.selenium.schedule;


import com.alibaba.fastjson.JSON;
import com.share.example.selenium.service.IBaseConfService;
import com.share.example.selenium.service.alibaba.buy.AlibabaClickGridBoxService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Map;

@Slf4j
@Component


public class alibaba_buy_schedule {
    @Autowired
    private IBaseConfService baseConfService;

    @Autowired
    private AlibabaClickGridBoxService alibabaClickGridBoxService;

    //每天执行一次---删除历史任务
    @Scheduled(cron = "0 0 10 * * ?")
    public void batchClosePromotion() {
        String key = baseConfService.getUserCode() + "_alibaba";
        if (!"enable".equals(baseConfService.getByCode(key))) {
            log.info("key={},没有配置", key);
            return;
        }

        Map<String, Object> tableLight = alibabaClickGridBoxService.batchClickGrid(40, "Table light", "Shenzhen Founder Industrial Co., Ltd");
        log.info("tableLight任务信息:", JSON.toJSONString(tableLight));

        Map<String, Object> ledTableLamp = alibabaClickGridBoxService.batchClickGrid(70, "Led table lamp", "Shenzhen Founder Industrial Co., Ltd");
        log.info("ledTableLamp任务信息:", JSON.toJSONString(ledTableLamp));

        Map<String, Object> ledDeskLamp = alibabaClickGridBoxService.batchClickGrid(50, "Led desk lamp", "Shenzhen Founder Industrial Co., Ltd");
        log.info("ledDeskLamp任务信息:", JSON.toJSONString(ledDeskLamp));
    }
}
